import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import getters from './getters'
import actions from './action'
import mutations from './mutations'
import state from './state'

//挂载Vuex
Vue.use(Vuex)

const store = new Vuex.Store({
    state: state,
    getters: getters,
    mutations: mutations,
    actions: actions,
    plugins: [
        new createPersistedState({
            storage: window.sessionStorage
            // storage: {
            //     getItem: key => window.sessionStorage.getItem(key),
            //     setItem: (key, value) => window.sessionStorage.setItem(key, value),
            //     removeItem: key => window.sessionStorage.removeItem(key)
            // }
        })
    ]
})

export default store